package main

import (
	"dgo/goutils/utils"
	"os"
	"os/exec"
	"time"
)

var (
	runner_map utils.GSyncMapGroup
)

type runner_rec struct {
	id      string
	cmd     *exec.Cmd
	cmdline string
	startT  time.Time
	laserr  error
	endT    time.Time
}

func (this *runner_rec) Start() error {
	this.cmd = utils.GetExecShellCmd(this.cmdline)
	this.cmd.Stdin = os.Stdin
	this.cmd.Stdout = os.Stdout
	this.cmd.Stderr = os.Stderr
	this.startT = time.Now()
	return this.cmd.Start()
}

func (this *runner_rec) Start2(settingio bool) error {
	this.cmd = utils.GetExecShellCmd(this.cmdline)
	if settingio {
		this.cmd.Stdin = os.Stdin
		this.cmd.Stdout = os.Stdout
		this.cmd.Stderr = os.Stderr
	}

	this.startT = time.Now()
	return this.cmd.Start()
}

func (this *runner_rec) Wait() {
	this.laserr = this.cmd.Wait()
	this.endT = time.Now()
}

func (this *runner_rec) Exec() error {
	this.startT = time.Now()
	this.cmd = utils.GetExecShellCmd(this.cmdline)
	this.cmd.Stdin = os.Stdin
	this.cmd.Stdout = os.Stdout
	this.cmd.Stderr = os.Stderr
	this.laserr = this.cmd.Run()
	this.endT = time.Now()
	return this.laserr
}
